# -*- coding: utf-8 -*-
"""
存放一些辅助的程序。
"""


def get_create_base_sql():
    for i in range(28, 59):
        print('# {} \n'.format(i))


def normalization(temp_list):
    return [data.strip() for data in temp_list if data.strip()]


def sql_split(sql_str, table_name):
    """
    将创建数据表的SQL语句拆分，并拼接成插入数据库的语句。
    :return:
    """
    print('INSERT INTO '+table_name+'(')

    sql_list = sql_str.split(',')
    for i in normalization(sql_list):
        item = i.split('  ')
        print(item[0]+',')

    print(')')
    print('VALUES('+'%s,'*len(normalization(sql_list))+');')


if __name__ == '__main__':
    table_name = 'team_superstar_peak_season_data'
    sql_str = """
    spsd_name  varchar(100)  NOT NULL  COMMENT '球队',
    spsd_player  varchar(100)  NOT NULL  COMMENT '球员',
    spsd_season  varchar(100)  COMMENT '赛季',
    spsd_seasons  varchar(100)  COMMENT '场次',
    spsd_average_score  varchar(100)  COMMENT '场均得分',
    spsd_average_backboard  varchar(100)  COMMENT '场均篮板',
    spsd_average_assists  varchar(100)  COMMENT '场均助攻',
    spsd_average_cap  varchar(100)  COMMENT '场均盖帽',
    spsd_average_steal  varchar(100)  COMMENT '场均抢断',
    """
    sql_split(sql_str, table_name)
